package io.renren.modules.dangan.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.dangan.entity.DaUserWjqxEntity;
import io.renren.modules.dangan.service.DaUserWjqxService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * ${comments}
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2019-09-02 22:01:21
 */
@RestController
@RequestMapping("danganSys/dauserwjqx")
public class DaUserWjqxController {
    @Autowired
    private DaUserWjqxService daUserWjqxService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("dangan:dauserwjqx:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = daUserWjqxService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{recid}")
    @RequiresPermissions("dangan:dauserwjqx:info")
    public R info(@PathVariable("recid") String recid){
        DaUserWjqxEntity daUserWjqx = daUserWjqxService.getById(recid);

        return R.ok().put("daUserWjqx", daUserWjqx);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("dangan:dauserwjqx:save")
    public R save(@RequestBody DaUserWjqxEntity daUserWjqx){
        daUserWjqxService.save(daUserWjqx);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("dangan:dauserwjqx:update")
    public R update(@RequestBody DaUserWjqxEntity daUserWjqx){
        ValidatorUtils.validateEntity(daUserWjqx);
        daUserWjqxService.updateById(daUserWjqx);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("dangan:dauserwjqx:delete")
    public R delete(@RequestBody String[] recids){
        daUserWjqxService.removeByIds(Arrays.asList(recids));

        return R.ok();
    }

}
